; Patrick Tessier
;1200x1600
; this script is used to test Papyrus class diagram
#include <library.au3>

$ClassPackagey=260 ;y of the package button
$ClassPackageItemy=280 ;y of the package button
$ClassModely=313; in packagetoolBox
$ClassProfiley=325; in packagetoolBox
$ClassButtony=280; y of the class button
$PrimitiveTypeButton=320; y of the class button
$DatatypeItem=360; y of Datatype item
$EnumerationItem=382; y of Enmeration Item
$CommentButton=400
$ConstraintButton=420



$PosFirstX=1050; first position of the element
$PosFirstY=221
$Pos2X=500; second position of the element (after moving)
$Pos2Y=500
$PosContainerX=500; position of the container
$PosContainerY=100


; main

func TestNode()
	MsgBox(0, "Test of a class diagram", "Test Node of a class diagram!")
	Opt("WinWaitDelay",100)
	Opt("WinTitleMatchMode",4)
	Opt("WinDetectHiddenText",1)
	Opt("MouseCoordMode",0)
	WinWait("Papyrus - umlExample1.di2 - Eclipse SDK","An overview is not a")
	If Not WinActive("Papyrus - umlExample1.di2 - Eclipse SDK","An overview is not a") Then WinActivate("Papyrus - umlExample1.di2 - Eclipse SDK","An overview is not a")
	WinWaitActive("Papyrus - umlExample1.di2 - Eclipse SDK","An overview is not a")

	selectElement($ClassPackagey,$ClassPackageItemy)	
	createContainer();
	;package
	selectElement($ClassPackagey,$ClassPackageItemy)	
	completeTestElement($ClassPackagey)
	;model
	selectElement($ClassPackagey,$ClassModely)	
	completeTestElement($ClassPackagey)
	;profile
	selectElement($ClassPackagey,$ClassProfiley)
	completeTestElement($ClassPackagey)

	;class
	selectClass()
	completeTestElement($ClassButtony)
	;interface
	selectInterface()
	completeTestElement($ClassButtony)
	;signal
	selectSignal()
	completeTestElement($ClassButtony)
	;sinstancespecification
	selectinstancespecification()
	completeTestElement($ClassButtony)

	;primitiveType
	completeTestElement($PrimitiveTypeButton)
	;Datatype
	selectElement($PrimitiveTypeButton,$DatatypeItem)
	completeTestElement($PrimitiveTypeButton)
	;Enumeration
	selectElement($PrimitiveTypeButton,$EnumerationItem)
	completeTestElement($PrimitiveTypeButton)

	;Comment
	completeTestElement($CommentButton)
	;Constraint
	completeTestElement($ConstraintButton)
EndFunc


;use to select an element in the palette of a class
Func SelectInClassBox($value)
	MouseMove($PaletteChangex,$ClassButtony)
	MouseDown("left")
	MouseUp("left")
	MouseMove(1441,$value)
	MouseDown("left")
	MouseUp("left")
EndFunc

;use to select class in the pallette
Func selectClass()
	SelectInClassBox(300)
EndFunc

;use to select interface in the pallette
Func selectInterface()
	SelectInClassBox(319)
EndFunc
; use to select signal
Func selectSignal()
	SelectInClassBox(340)
EndFunc
;use to select instancespecification
Func selectinstancespecification()
	SelectInClassBox(360)
EndFunc


; to run of complete test on a element
Func completeTestElement($Element)
	
	TestElementCreation($Element,$PosFirstX,$PosFirstY)
	shoot()
	controlZ()
	shoot()
	controlY()
	shoot()

	Sleep(3000)
	TestGraphicalDeletion($PosFirstX,$PosFirstY)
	shoot()
	controlZ()
	shoot()
	controlY()
	shoot()
	controlZ()


	Sleep(3000)
	TestDeletion($PosFirstX,$PosFirstY)
	shoot()
	controlZ()
	shoot()
	controlY()
	shoot()
	controlZ()

	Sleep(3000)
	Move()
	shoot()
	controlZ()
	shoot()
	controlY()
	shoot()

	MoveInContainer();
	shoot()
	controlZ()
	shoot()
	controlY()
	shoot()
	controlZ()


	TestRezise($Pos2X,$Pos2Y)
	shoot()
	controlZ()
	shoot()
	controlY()
	shoot()
	TestDeletion($Pos2X,$Pos2Y)
EndFunc


; move into pos2
Func Move()
	WinWait("Papyrus - umlExample1.di2 - Eclipse SDK","")
	If Not WinActive("Papyrus - umlExample1.di2 - Eclipse SDK","") Then WinActivate("Papyrus - umlExample1.di2 - Eclipse SDK","")
	WinWaitActive("Papyrus - umlExample1.di2 - Eclipse SDK","")
	MouseMove($PosFirstX+5,$PosFirstY+5)
	MouseDown("left")
	MouseMove($Pos2X,$Pos2Y)
	MouseUp("left")
EndFunc

; return at the first position
Func returnMove()
	WinWait("Papyrus - umlExample1.di2 - Eclipse SDK","")
	If Not WinActive("Papyrus - umlExample1.di2 - Eclipse SDK","") Then WinActivate("Papyrus - umlExample1.di2 - Eclipse SDK","")
	WinWaitActive("Papyrus - umlExample1.di2 - Eclipse SDK","")
	MouseMove($Pos2X+5,$Pos2Y+5)
	MouseDown("left")
	MouseMove($PosFirstX,$PosFirstY)
	MouseUp("left")
EndFunc

; move element in the container
Func MoveInContainer()
	WinWait("Papyrus - umlExample1.di2 - Eclipse SDK","")
	If Not WinActive("Papyrus - umlExample1.di2 - Eclipse SDK","") Then WinActivate("Papyrus - umlExample1.di2 - Eclipse SDK","")
	WinWaitActive("Papyrus - umlExample1.di2 - Eclipse SDK","")
	MouseMove($Pos2X+5,$Pos2Y+5)
	MouseDown("left")
	MouseMove($PosContainerX+40,$PosContainerY+40)
	MouseUp("left")
EndFunc

; create a container
Func createContainer()
	WinWait("Papyrus - umlExample1.di2 - Eclipse SDK","")
	If Not WinActive("Papyrus - umlExample1.di2 - Eclipse SDK","") Then WinActivate("Papyrus - umlExample1.di2 - Eclipse SDK","")
	WinWaitActive("Papyrus - umlExample1.di2 - Eclipse SDK","")
	MouseMove($PaletteButtonx,$ClassPackagey)
	MouseDown("left")
	MouseUp("left")
	MouseMove($PosContainerX,$PosContainerY)
	MouseDown("left")
	MouseMove($PosContainerX+400,$PosContainerY+200)
	MouseUp("left")
EndFunc

